package com.ccq.controller;

import com.ccq.model.Second;
import com.ccq.service.AboutService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value = {"front"})
public class AboutController {
    @Autowired
    AboutService aboutService;


    @ApiOperation(value = "二手细节", notes = "二手细节")
    @RequestMapping(value = {"detail/{id}"}, method = RequestMethod.GET)
    public ModelAndView detail(@PathVariable("id") int id, ModelAndView modelAndView) {
        Second s = aboutService.basicdata(id);
        modelAndView.addObject("detail", s);
        modelAndView.setViewName("about");
        return modelAndView;
    }

    @ApiOperation(value = "二手细节", notes = "二手细节")
    @RequestMapping(value = {"detail1/{id}"}, method = RequestMethod.GET)
    public ModelAndView detail1(@PathVariable("id") int id, ModelAndView modelAndView) {
        Second s = aboutService.basicdata(id);
        modelAndView.addObject("detail1", s);
        modelAndView.setViewName("about1");
        return modelAndView;
    }

    @ApiOperation(value="基本记录",notes = "基本记录")
    @RequestMapping(value = { "basiclists" },method = RequestMethod.POST)
    @ResponseBody
    public String basiclists(String id){
        int temp=Integer.parseInt(id);
        String ls=aboutService.record(temp);
        return ls;
    }


}
